package com.ihighest.app.infox.tools;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 
 * 数据格式验证工具
 * 
 * 
 * @author Administrator Created at 2015-10-15 下午5:01:58
 * @version 1.0
 */
public class RegexKit {
	/**
	 * 
	 * 
	 * @param mobiles
	 * @return
	 */
	public static boolean isMobile(String mobiles) {

		String telRegex = "[1][3578]\\d{9}";
		Pattern p = Pattern.compile(telRegex);
		Matcher m = p.matcher(mobiles);

		return m.matches();
	}

	/**
	 * 
	 * 
	 * @param email
	 * @return
	 */
	public static boolean isEmail(String email) {
		String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
		Pattern p = Pattern.compile(str);
		Matcher m = p.matcher(email);

		return m.matches();
	}

	/**
	 * 验证身份证号码、、（不严格）
	 * 
	 * @param text
	 * 
	 * @return
	 */
	public static boolean personIdValidation(String text) {
		String regx = "[0-9]{17}x";
		String reg1 = "[0-9]{15}";
		String regex = "[0-9]{18}";
		return text.matches(regx) || text.matches(reg1) || text.matches(regex);
	}

	/**
	 * 验证银行卡号
	 * 
	 * @param text
	 * @return
	 */
	public static boolean isBankCard(String text) {
		String regx = "^\\d{19}$";
		return text.matches(regx);
	}

	/**
	 * 名字格式判断
	 * 
	 * @param text
	 * @return
	 */
	public static boolean isName(String text) {
		String regx = "^([\u4e00-\u9fa5]){2,7}$";
		return text.matches(regx);
	}

	/**
	 * 
	 * 检验psd格式
	 * 
	 * @param psd
	 * @return
	 */

	public static boolean isPassword(String pwd) {
		String str = "^[a-zA-Z0-9]{6,20}$";
		Pattern p = Pattern.compile(str);
		Matcher m = p.matcher(pwd);
		return m.matches();

	}

}
